package es.springdataes.domain.repository;

import es.springdataes.domain.Book;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

/**
 * 接口关系：
 * ElasticsearchRepository --> ElasticsearchCrudRepository -->
 * PagingAndSortingRepository --> CrudRepository
 */
public interface BookRepository extends ElasticsearchRepository<Book, String> {

    List<Book> findByTitle(String title) ;
    //Optional<Book> findById(String id);

    /**
     * And
     */
    List<Book> findByTitleAndSaleCnt(String title, Long sale) ;
//
//
    /**
     * Not
     * @param title
     * @param pageable
     * @return
     */
    Page<Book> findByTitleNot(String title, Pageable pageable);
//
    /**
     * 分页
     */
    Page<Book> findByTitle(String title, Pageable pageable);

    /**
     * Like
     * @param title
     * @param pageable
     * @return
     */
    Page<Book> findByTitleLike(String title, Pageable pageable);



}